package jhsys.mc.rs.msg;

import android.util.Log;
import jhsys.mc.basepage.MCApplication;
import jhsys.mc.rs.net.MulticastUtil;

public class MSEARCHACK {
	private String HTTPTAG = "HTTP/1.1 200 OK";
	private String CACHECONTROL = "1800";
	private String HOST = "239.255.255.250:1900";
	private String DATE = "Tue, 10 Jan 2006 23:55:33 GMT";
	private String EXT = "";
	private String LOCATION = "http://192.168.1.1:1900/igd.xml";
	private String SERVER = "UPnP/1.0";
	private String ST = "schemas-UPnP-org:device:SmartHomeController:1";
	private String USN = "uuid:192168115678900000::urn:schemas-UPnP-org:device:SmartHomeController:1";
	private static final String END = "\r\n";

	public String toString() {
		setUUID();
		StringBuffer buffer = new StringBuffer();
		buffer.append(HTTPTAG + END);
		buffer.append("HOST:" + HOST + END);
		buffer.append("CACHE-CONTROL:max-age=" + CACHECONTROL + END);
		buffer.append("DATE:" + DATE + END);
		buffer.append("EXT:" + EXT + END);
		buffer.append("LOCATION:" + LOCATION + END);
		buffer.append("SERVER:" + SERVER + END);
		buffer.append("ST:" + ST + END);
		buffer.append("USN:" + USN + END + END);
		return buffer.toString();
	}

	public String getHTTPTAG() {
		return HTTPTAG;
	}

	public void setHTTPTAG(String hTTPTAG) {
		HTTPTAG = hTTPTAG;
	}

	public String getCACHECONTROL() {
		return CACHECONTROL;
	}

	public void setCACHECONTROL(String cACHECONTROL) {
		CACHECONTROL = cACHECONTROL;
	}

	public String getDATE() {
		return DATE;
	}

	public void setDATE(String dATE) {
		DATE = dATE;
	}

	public String getEXT() {
		return EXT;
	}

	public void setEXT(String eXT) {
		EXT = eXT;
	}

	public String getLOCATION() {
		return LOCATION;
	}

	public void setLOCATION(String lOCATION) {
		LOCATION = lOCATION;
	}

	public String getSERVER() {
		return SERVER;
	}

	public void setSERVER(String sERVER) {
		SERVER = sERVER;
	}

	public String getST() {
		return ST;
	}

	public void setST(String sT) {
		ST = sT;
	}

	public String getUSN() {
		return USN;
	}

	public void setUSN(String uSN) {
		USN = uSN;
	}

	public void setHOST(String hOST) {
		HOST = hOST;
	}
	
	private void setUUID(){
		String registryNum=MCApplication.localMacAdress;

		try {
			registryNum=registryNum.replace(":", "").toUpperCase();
			registryNum=registryNum.replace(".", "").trim();
		} catch (Exception e) {
			// TODO: handle exception
			registryNum="123456789ABC";
		}
		setUSN("uuid:123456" + registryNum
				+ "::urn:schemas-UPnP-org:device:SmartHomeController:1");
	}
	
}
